<%--
  Created by IntelliJ IDEA.
  User: CrazyTobis
  Date: 2020-05-11
  Time: 21:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div id="tcjDetail">
<div class="" id="">
    <div class="row">
        <div class="col-3">

            <input data-tcj="order" class="form-control "readonly value="入库单号:${vo.receptNo}">

        </div>


        <div class="col-2">
            <c:choose>
                <c:when test="${vo.name eq '采购入库'}">

            <input class="form-control "readonly value="入库类型:${vo.name}">

                </c:when>
                <c:otherwise>
                <select class="form-control" name="type">

                    <c:forEach items="${type}" var="obj">
                    <option value="${obj.id}">${obj.name}</option>
                    </c:forEach>
                </select>
                </c:otherwise>
            </c:choose>
        </div>



        <div class="col-2">
            <input class="form-control "readonly value="单据状态:${vo.result}">
        </div>
        <div class="col-5">
            <input class="form-control " value="入库备注:${vo.remakers}">
        </div>
    </div>
</div>

<div id="MyTable">

</div>
<div class="alert alert-secondary" role="alert" data-tcj="all" style="color: #0A160A">

</div>


<div>
    <div style="top: 0px;
    left: -5px;
    width: 159px;
    height: 30px;
    background: #e2f3ff;
    border-radius: 0 17px 17px 0;
    color: #2397f3;
    text-align: center;
    line-height: 30px;">

                经办信息
    </div>
    <div id="infoTable" style="padding-bottom: 50px"></div>
</div>
    <div class="text-right">
        <button data-tcj="detail-tijiao" class="btn btn-danger mr-4">提交</button>
        <button data-tcj="detail-back"  class="btn btn-primary">返回</button>
    </div>

</div>
<script>
    (function () {

        let pageVO = ${pageVO};
        //总数
        let totle = 0;
        //完好数
        let good = 0;
        //破损数
        let band = 0;

        for (let i = 0; i<pageVO.data.length;i++){

            let data = pageVO.data[i];
           totle+=data.receptAmount;
           good += data.completeAmount;
           band+=data.brokenAmount;
        }
        let content = "合计：     物品种类: "+pageVO.data.length+ "          物品总数：  "+totle+"       完好品总数：  "+good+"      破损品总数:   "+band;

        $('[data-tcj="all"]').html(content);
        let columns =[{field: "id", title: "编号"},
            {field: "goodsName", title: "物品名称"},
            {field: "receptAmount", title: "入库数量"},
            {field: "completeAmount", title: "商品完好数"},
            {field: "brokenAmount", title: "破损数"},
            {field: "remarks", title: "备注"},
            {field: "shelves", title: "位置"},
            {field: "gys", title: "供应商"},
            {field: "value", title: "尺寸"},
            {field: "name", title: "颜色"}];

        let options={
            pageVO:pageVO,
            node:"#MyTable",
            columns:columns,
            isPaging:false,
            isChecked:false

        }
        firstTable(options);

        let info =   ${info};

        columns = [{filed: "type", title: "流程名称"},
       {filed: "name", title: "经办人"},
       {filed: "infoTime", title: "提交时间"},
       {filed: "remarks", title: "备注"},
        {filed: "result", title: "结果"}];
        firstTable({
            pageVO: info,
            columns: columns,
            node:"#infoTable",
            isPaging:false,
            isChecked:false
        });
    //提交监听
        $('[data-tcj="detail-tijiao" ]').on('click',function () {
            //将单据状态改变
           // 获取当前订单编号
            let order = `${vo.receptNo}`;
            console.log(order)
            let sendSbil = [order];
            console.log(sendSbil)
            $.ajax({
                url:'submit',
                type:'post',
                dataType: 'json',
                traditional:true,
                data:{'提交':sendSbil},
                success:function (e) {
                    console.log(e)
                    if(e>0){
                        alert("提交成功");

                        $('').returnMianbao();
                        $.getMenuData('chanpinruku').start($(getShowPane()).find('chanpinruku'));

                    }else{
                        alert("提交失败");
                        $('').returnMianbao();
                    }
                }
            });
        });
        //返回监听
        $('[data-tcj="detail-back" ]').on('click',function () {
            $('').returnMianbao();
        })
    })();
</script>